package com.jgdt.jgdtkasannong_university_gene_backend.service.base.impl;


import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jgdt.jgdtkasannong_university_gene_backend.common.response.PageRequest;
import com.jgdt.jgdtkasannong_university_gene_backend.dto.CameraDeviceSequenceDto;
import com.jgdt.jgdtkasannong_university_gene_backend.entity.base.CameraDevice;
import com.jgdt.jgdtkasannong_university_gene_backend.mapper.base.CameraDeviceMapper;
import com.jgdt.jgdtkasannong_university_gene_backend.service.base.CameraDeviceService;
import com.jgdt.jgdtkasannong_university_gene_backend.vo.base.QueryBaseInfoByIdParameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 摄像头设备表 服务实现类
 * </p>
 *
 * @author chenzg
 * @since 2025-04-27
 */
@Service
public class CameraDeviceServiceImpl extends ServiceImpl<CameraDeviceMapper, CameraDevice> implements CameraDeviceService {

    @Autowired
    private CameraDeviceMapper cameraDeviceMapper;


    @Override
    public List<CameraDevice> queryCameraDeviceByBaseId(List<Integer> baseIds) {
        if(CollectionUtil.isEmpty(baseIds)){
            return new ArrayList<>();
        }
        LambdaQueryWrapper<CameraDevice> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.in(CameraDevice::getBaseId,baseIds);
        return list(queryWrapper);
    }

    @Override
    public IPage<CameraDeviceSequenceDto> getCameraDeviceSequenceDtoPage(PageRequest<QueryBaseInfoByIdParameter> requestPage) {
        Page<QueryBaseInfoByIdParameter> page=new Page<>(requestPage.getPageNum(),requestPage.getPageSize());
        return cameraDeviceMapper.getCameraDeviceSequenceDtoPage(page,requestPage.getCondition().getBaseId());
    }
}
